/*
 * SPDX-License-Identifier: GPL-2.0
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2023. All rights reserved.
 * Description:
 * Author: -
 * Create: 2021.4.19
 */

#include "ossl_knl.h"
#include "hiudk3.h"
#include "hiudk_internal.h"

/**
 * @brief hiudk_cos_valid_bitmap - get cos valid bitmap
 * @param udkdev: device pointer to udkdev
 * @retval non-zero: valid cos bit map
 * @retval zero: failure
 */
int hiudk_cos_valid_bitmap(void *udkdev, u8 *func_dft_cos, u8 *port_cos_bitmap)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_cos_valid_bitmap != NULL))) {
        return ops->crm_ops.hiudk_cos_valid_bitmap(sdk_hwdev, func_dft_cos, port_cos_bitmap);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_cos_valid_bitmap);

int hiudk_get_slave_host_enable(void *udkdev, u8 host_id, u8 *slave_en)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_slave_host_enable != NULL))) {
        return ops->crm_ops.hiudk_get_slave_host_enable(sdk_hwdev, host_id, slave_en);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_get_slave_host_enable);

int hiudk_get_slave_bitmap(void *udkdev, u8 *slave_host_bitmap)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_slave_bitmap != NULL))) {
        return ops->crm_ops.hiudk_get_slave_bitmap(sdk_hwdev, slave_host_bitmap);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_get_slave_bitmap);

int hiudk_get_host_migrate_enable(void *udkdev, u8 host_id, u8 *migrate_en)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_host_migrate_enable != NULL))) {
        return ops->crm_ops.hiudk_get_host_migrate_enable(sdk_hwdev, host_id, migrate_en);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_get_host_migrate_enable);

int hiudk_set_host_migrate_enable(void *udkdev, u8 host_id, bool enable)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_set_host_migrate_enable != NULL))) {
        return ops->crm_ops.hiudk_set_host_migrate_enable(sdk_hwdev, host_id, enable);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_set_host_migrate_enable);

/**
 * @brief hiudk_er_id - get ep id
 * @param udkdev: device pointer to udkdev
 * @retval ep id
 */
u8 hiudk_ep_id(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_ep_id != NULL))) {
        return ops->crm_ops.hiudk_ep_id(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_ep_id);

/**
 * @brief hiudk_er_id - get er id
 * @param udkdev: device pointer to udkdev
 * @retval er id
 */
u8 hiudk_er_id(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_er_id != NULL))) {
        return ops->crm_ops.hiudk_er_id(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_er_id);

/**
 * @brief hiudk_fault_event_report - report fault event
 * @param udkdev: device pointer to udkdev
 * @param src: fault event source, reference to enum hinic3_fault_source_type
 * @param level: fault level, reference to enum hinic3_fault_err_level
 */
void hiudk_fault_event_report(void *udkdev, u16 src, u16 level)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_fault_event_report != NULL))) {
        return ops->crm_ops.hiudk_fault_event_report(sdk_hwdev, src, level);
    }
    pr_err("ops is NULL! \n");
    return;
}

EXPORT_SYMBOL(hiudk_fault_event_report);

/*
 * @brief hiudk_flexq_en get flexq en
 */
u8 hiudk_flexq_en(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_flexq_en != NULL))) {
        return ops->crm_ops.hiudk_flexq_en(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_flexq_en);

/*
 * @brief hiudk_get_fake_vf_info get fake_vf info
 */
int hiudk_get_fake_vf_info(void *udkdev, u8 *fake_vf_vld, u8 *page_bit, u8 *pf_start_bit, u8 *map_host_id)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;
 
    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }
 
    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_fake_vf_info != NULL))) {
        return ops->crm_ops.hiudk_get_fake_vf_info(sdk_hwdev, fake_vf_vld, page_bit, pf_start_bit, map_host_id);
    }
    pr_err("ops is NULL! \n");
    return 0;
}
 
EXPORT_SYMBOL(hiudk_get_fake_vf_info);

u32 hiudk_host_pf_num(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_host_pf_num != NULL))) {
        return ops->crm_ops.hiudk_host_pf_num(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_host_pf_num);

u32 hiudk_host_pf_id_start(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_host_pf_id_start != NULL))) {
        return ops->crm_ops.hiudk_host_pf_id_start(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_host_pf_id_start);

/**
 * @brief hiudk_func_max_qnum - get max queue number
 * @param udkdev: device pointer to udkdev
 * @retval non-zero: max queue number
 * @retval zero: failure
 */
u16 hiudk_func_max_qnum(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_func_max_qnum != NULL))) {
        return ops->crm_ops.hiudk_func_max_qnum(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_func_max_qnum);

/**
 * @brief hiudk_func_max_vf - get vf number
 * @param udkdev: device pointer to udkdev
 * @retval non-zero: vf number
 * @retval zero: failure
 */
u16 hiudk_func_max_vf(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_func_max_vf != NULL))) {
        return ops->crm_ops.hiudk_func_max_vf(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_func_max_vf);

/**
 * @brief hiudk_func_rx_tx_flush - function flush
 * @param udkdev: device pointer to udkdev
 * @param channel: channel id
 * @retval zero: success
 * @retval non-zero: failure
 */
int hiudk_func_rx_tx_flush(void *udkdev, u16 channel, bool wait_io)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_func_rx_tx_flush != NULL))) {
        return ops->crm_ops.hiudk_func_rx_tx_flush(sdk_hwdev, channel, wait_io);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_func_rx_tx_flush);

/**
 * @brief hiudk_func_type - get function type
 * @param udkdev: device pointer to udkdev
 * @retval function type
 */
enum func_type hiudk_func_type(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_func_type != NULL))) {
        return ops->crm_ops.hiudk_func_type(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_func_type);

/**
 * @brief hiudk_get_card_present_state - get card present state
 * @param udkdev: device pointer to udkdev
 * @param card_present_state: return card present state
 * @retval zero: success
 * @retval non-zero: failure
 */
int hiudk_get_card_present_state(void *udkdev, bool *card_present_state)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_card_present_state != NULL))) {
        return ops->crm_ops.hiudk_get_card_present_state(sdk_hwdev, card_present_state);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_get_card_present_state);

/**
 * @brief hiudk_get_chip_present_flag - get chip present flag
 * @param udkdev: device pointer to udkdev
 * @retval 1: chip is present
 * @retval 0: chip is absent
 */
int hiudk_get_chip_present_flag(const void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_chip_present_flag != NULL))) {
        return ops->crm_ops.hiudk_get_chip_present_flag(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_get_chip_present_flag);

/**
 * @brief hiudk_get_fw_version - get firmware version
 * @param udkdev: device pointer to udkdev
 * @param fw_ver: firmware version
 * @param channel: channel id
 * @retval zero: success
 * @retval non-zero: failure
 */
int hiudk_get_fw_version(void *udkdev, struct hinic3_fw_version *fw_ver, u16 channel)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_fw_version != NULL))) {
        return ops->crm_ops.hiudk_get_fw_version(sdk_hwdev, fw_ver, channel);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_get_fw_version);

/**
 * @brief hiudk_get_heartbeat_status - get heartbeat status
 * @param udkdev: device pointer to udkdev
 * @retval heartbeat status
 */
u32 hiudk_get_heartbeat_status(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_heartbeat_status != NULL))) {
        return ops->crm_ops.hiudk_get_heartbeat_status(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_get_heartbeat_status);

/**
 * @brief hiudk_get_mgmt_version - get management cpu version
 * @param udkdev: device pointer to udkdev
 * @param mgmt_ver: output management version
 * @param channel: channel id
 * @retval zero: success
 * @retval non-zero: failure
 */
int hiudk_get_mgmt_version(void *udkdev, u8 *mgmt_ver, u8 version_size, u16 channel)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_mgmt_version != NULL))) {
        return ops->crm_ops.hiudk_get_mgmt_version(sdk_hwdev, mgmt_ver, version_size, channel);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_get_mgmt_version);

/**
 * @brief hiudk_glb_pf_vf_offset - get vf offset id of pf
 * @param udkdev: device pointer to udkdev
 * @retval vf offset id
 */
u16 hiudk_glb_pf_vf_offset(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_glb_pf_vf_offset != NULL))) {
        return ops->crm_ops.hiudk_glb_pf_vf_offset(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_glb_pf_vf_offset);

/**
 * @brief hiudk_get_bond_create_mode - get bond create mode
 * @param udkdev: device pointer to udkdev
 * @retval bond create mode
 */
u8 hiudk_get_bond_create_mode(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_bond_create_mode != NULL))) {
        return ops->crm_ops.hiudk_get_bond_create_mode(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_get_bond_create_mode);

/**
 * @brief hiudk_global_func_id - get global function id
 * @param udkdev: device pointer to udkdev
 * @retval global function id
 */
u16 hiudk_global_func_id(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_global_func_id != NULL))) {
        return ops->crm_ops.hiudk_global_func_id(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_global_func_id);

/**
 * @brief hiudk_host_id - get host id
 * @param udkdev: device pointer to udkdev
 * @retval host id
 */
u8 hiudk_host_id(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_host_id != NULL))) {
        return ops->crm_ops.hiudk_host_id(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_host_id);

/**
 * @brief hiudk_host_oq_id_mask - get oq id
 * @param udkdev: device pointer to udkdev
 * @retval oq id
 */
u8 hiudk_host_oq_id_mask(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_host_oq_id_mask != NULL))) {
        return ops->crm_ops.hiudk_host_oq_id_mask(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_host_oq_id_mask);

/**
 * @brief hiudk_func_max_qnum - get host total function number
 * @param udkdev: device pointer to udkdev
 * @retval non-zero: host total function number
 * @retval zero: failure
 */
u16 hiudk_host_total_func(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_host_total_func != NULL))) {
        return ops->crm_ops.hiudk_host_total_func(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_host_total_func);

/*
 * @brief hiudk_intr_num get intr num
 */
u16 hiudk_intr_num(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_intr_num != NULL))) {
        return ops->crm_ops.hiudk_intr_num(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_intr_num);

/*
 * @brief hiudk_max_pf_num - get global max pf number
 */
u8 hiudk_max_pf_num(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_max_pf_num != NULL))) {
        return ops->crm_ops.hiudk_max_pf_num(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_max_pf_num);

/**
 * @brief hiudk_misx_intr_clear_resend_bit - clear msix resend bit
 * @param udkdev: device pointer to udkdev
 * @param msix_idx: msix id
 * @param clear_resend_en: 1-clear
 */
void hiudk_misx_intr_clear_resend_bit(void *udkdev, u16 msix_idx, u8 clear_resend_en)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_misx_intr_clear_resend_bit != NULL))) {
        return ops->crm_ops.hiudk_misx_intr_clear_resend_bit(sdk_hwdev, msix_idx, clear_resend_en);
    }
    pr_err("ops is NULL! \n");
    return;
}

EXPORT_SYMBOL(hiudk_misx_intr_clear_resend_bit);

/**
 * @brief hiudk_pcie_itf_id - get pcie port id
 * @param udkdev: device pointer to udkdev
 * @retval pcie port id
 */
u8 hiudk_pcie_itf_id(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_pcie_itf_id != NULL))) {
        return ops->crm_ops.hiudk_pcie_itf_id(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_pcie_itf_id);

/**
 * @brief hiudk_pf_id_of_vf - get pf id of vf
 * @param udkdev: device pointer to udkdev
 * @retval pf id
 */
u8 hiudk_pf_id_of_vf(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_pf_id_of_vf != NULL))) {
        return ops->crm_ops.hiudk_pf_id_of_vf(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_pf_id_of_vf);

/**
 * @brief hiudk_physical_port_id - get physical port id
 * @param udkdev: device pointer to udkdev
 * @retval physical port id
 */
u8 hiudk_physical_port_id(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_physical_port_id != NULL))) {
        return ops->crm_ops.hiudk_physical_port_id(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_physical_port_id);

/**
 * @brief hiudk_ppf_idx - get ppf id
 * @param udkdev: device pointer to udkdev
 * @retval ppf id
 */
u8 hiudk_ppf_idx(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_ppf_idx != NULL))) {
        return ops->crm_ops.hiudk_ppf_idx(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_ppf_idx);

/**
 * @brief hiudk_set_func_svc_used_state - set function service used state
 * @param udkdev: device pointer to udkdev
 * @param svc_type: service type
 * @param state: function used state
 * @param channel: channel id
 * @retval zero: success
 * @retval non-zero: failure
 */
int hiudk_set_func_svc_used_state(void *udkdev, u16 svc_type, u8 state, u16 channel)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_set_func_svc_used_state != NULL))) {
        return ops->crm_ops.hiudk_set_func_svc_used_state(sdk_hwdev, svc_type, state, channel);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_set_func_svc_used_state);

int hiudk_set_interrupt_cfg(void *udkdev, struct interrupt_info interrupt_info, u16 channel)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_set_interrupt_cfg != NULL))) {
        return ops->crm_ops.hiudk_set_interrupt_cfg(sdk_hwdev, interrupt_info, channel);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_set_interrupt_cfg);

void hiudk_set_msix_auto_mask_state(void *udkdev, u16 msix_idx, enum hinic3_msix_auto_mask flag)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_set_msix_auto_mask_state != NULL))) {
        return ops->crm_ops.hiudk_set_msix_auto_mask_state(sdk_hwdev, msix_idx, flag);
    }
    pr_err("ops is NULL! \n");
    return;
}

EXPORT_SYMBOL(hiudk_set_msix_auto_mask_state);

/**
 * @brief hiudk_set_msix_state - set msix state
 * @param udkdev: device pointer to udkdev
 * @param msix_idx: msix id
 * @param flag: msix state flag, 0-enable, 1-disable
 */
void hiudk_set_msix_state(void *udkdev, u16 msix_idx, enum hinic3_msix_state flag)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_set_msix_state != NULL))) {
        return ops->crm_ops.hiudk_set_msix_state(sdk_hwdev, msix_idx, flag);
    }
    pr_err("ops is NULL! \n");
    return;
}

EXPORT_SYMBOL(hiudk_set_msix_state);

int hiudk_set_ppf_flr_type(void *udkdev, enum hinic3_ppf_flr_type flr_type)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_set_ppf_flr_type != NULL))) {
        return ops->crm_ops.hiudk_set_ppf_flr_type(sdk_hwdev, flr_type);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_set_ppf_flr_type);

int hiudk_set_ppf_tbl_hotreplace_flag(void *udkdev, u8 flag)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_set_ppf_tbl_hotreplace_flag != NULL))) {
        return ops->crm_ops.hiudk_set_ppf_tbl_hotreplace_flag(sdk_hwdev, flag);
    }

    pr_err("ops is NULL! \n");
    return -EINVAL;
}

/**
 * @brief hiudk_vector_to_eqn - vector to eq id
 * @param udkdev: device pointer to udkdev
 * @param type: service type
 * @param vector: vertor
 * @retval eq id
 */
int hiudk_vector_to_eqn(void *udkdev, enum hinic3_service_type type, int vector)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_vector_to_eqn != NULL))) {
        return ops->crm_ops.hiudk_vector_to_eqn(sdk_hwdev, type, vector);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}

EXPORT_SYMBOL(hiudk_vector_to_eqn);

/**
 * @brief hiudk_vf_in_pf - get vf offset in pf
 * @param udkdev: device pointer to udkdev
 * @retval vf offset in pf
 */
u8 hiudk_vf_in_pf(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_vf_in_pf != NULL))) {
        return ops->crm_ops.hiudk_vf_in_pf(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_vf_in_pf);


/**
 * @brief hiudk_func_max_nic_qnum - get max nic queue number
 * @param udkdev: device pointer to udkdev
 * @retval non-zero: max nic queue number
 * @retval zero: failure
 */
u16 hiudk_func_max_nic_qnum(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_vf_in_pf != NULL))) {
        return ops->crm_ops.hiudk_func_max_nic_qnum(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}

EXPORT_SYMBOL(hiudk_func_max_nic_qnum);

int hiudk_is_slave_func(const void *udkdev, bool *is_slave_func)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_is_slave_func != NULL))) {
        return ops->crm_ops.hiudk_is_slave_func(sdk_hwdev, is_slave_func);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_is_slave_func);

int hiudk_is_master_func(const void *udkdev, bool *is_master_func)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_is_master_func != NULL))) {
        return ops->crm_ops.hiudk_is_master_func(sdk_hwdev, is_master_func);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_is_master_func);

bool hiudk_is_multi_bm(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_is_multi_bm != NULL))) {
        return ops->crm_ops.hiudk_is_multi_bm(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_is_multi_bm);

bool hiudk_is_slave_host(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_is_slave_host != NULL))) {
        return ops->crm_ops.hiudk_is_slave_host(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_is_slave_host);

bool hiudk_is_vm_slave_host(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_is_vm_slave_host != NULL))) {
        return ops->crm_ops.hiudk_is_vm_slave_host(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_is_vm_slave_host);

bool hiudk_is_bm_slave_host(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;
 
    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }
 
    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_is_bm_slave_host != NULL))) {
        return ops->crm_ops.hiudk_is_bm_slave_host(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_is_bm_slave_host);

bool hiudk_is_guest_vmsec_enable(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return 0;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_is_guest_vmsec_enable != NULL))) {
        return ops->crm_ops.hiudk_is_guest_vmsec_enable(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return 0;
}
EXPORT_SYMBOL(hiudk_is_guest_vmsec_enable);

int hiudk_get_vfid_by_vfpci(void *udkdev, struct pci_dev *pdev, u16 *global_func_id)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error!\n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_vfid_by_vfpci != NULL))) {
        return ops->crm_ops.hiudk_get_vfid_by_vfpci(sdk_hwdev, pdev, global_func_id);
    }
    pr_err("ops is NULL!\n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_get_vfid_by_vfpci);

int hiudk_set_func_nic_state(void *udkdev, struct hinic3_func_nic_state *state)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_set_func_nic_state != NULL))) {
        return ops->crm_ops.hiudk_set_func_nic_state(sdk_hwdev, state);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_set_func_nic_state);

int hiudk_get_netdev_state(void *udkdev, u16 func_idx, int *opened)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_netdev_state != NULL))) {
        return ops->crm_ops.hiudk_get_netdev_state(sdk_hwdev, func_idx, opened);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_get_netdev_state);

int hiudk_get_mhost_func_nic_enable(void *udkdev, u16 func_id, bool *en)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_mhost_func_nic_enable != NULL))) {
        return ops->crm_ops.hiudk_get_mhost_func_nic_enable(sdk_hwdev, func_id, en);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_get_mhost_func_nic_enable);

int hiudk_get_dev_cap(void *udkdev)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_dev_cap != NULL))) {
        return ops->crm_ops.hiudk_get_dev_cap(sdk_hwdev);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_get_dev_cap);

int hiudk_mbox_to_host_sync(void *udkdev, enum hinic3_mod_type mod,
			    u8 cmd, void *buf_in, u16 in_size,
			    void *buf_out, u16 *out_size, u32 timeout, u16 channel)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_mbox_to_host_sync != NULL))) {
        return ops->crm_ops.hiudk_mbox_to_host_sync(sdk_hwdev, mod, cmd,
            buf_in, in_size, buf_out, out_size, timeout, channel);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_mbox_to_host_sync);

int hiudk_get_func_vroce_enable(void *udkdev, u16 glb_func_idx, u8 *en)
{
    void *sdk_hwdev = NULL;
    struct hiudk_ops *ops = NULL;

    if (unlikely(!CHECK_UDK_DEV(udkdev))) {
        pr_err("udkdev is error! \n");
        return -EINVAL;
    }

    sdk_hwdev = GET_SDKHWDEV_FROM_HIUDKHWDEV(udkdev);
    ops = GET_SDKOPS_FROM_HIUDKHWDEV(udkdev);
    if (likely((ops != NULL) && (ops->crm_ops.hiudk_get_func_vroce_enable != NULL))) {
        return ops->crm_ops.hiudk_get_func_vroce_enable(sdk_hwdev, glb_func_idx, en);
    }
    pr_err("ops is NULL! \n");
    return -EINVAL;
}
EXPORT_SYMBOL(hiudk_get_func_vroce_enable);
